home *** CD-ROM | disk | FTP | other *** search
- package javax.swing.plaf.basic;
-
- import java.awt.Dimension;
- import java.awt.Graphics;
- import javax.swing.DefaultDesktopManager;
- import javax.swing.DesktopManager;
- import javax.swing.JComponent;
- import javax.swing.JDesktopPane;
- import javax.swing.KeyStroke;
- import javax.swing.UIManager;
- import javax.swing.plaf.ComponentUI;
- import javax.swing.plaf.DesktopPaneUI;
- import javax.swing.plaf.UIResource;
-
- public class BasicDesktopPaneUI extends DesktopPaneUI {
- private static Dimension minSize = new Dimension(0, 0);
- private static Dimension maxSize = new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
- protected JDesktopPane desktop;
- protected DesktopManager desktopManager;
- protected KeyStroke minimizeKey;
- protected KeyStroke maximizeKey;
- protected KeyStroke closeKey;
- protected KeyStroke navigateKey;
- protected KeyStroke navigateKey2;
-
- public static ComponentUI createUI(JComponent var0) {
- return new BasicDesktopPaneUI();
- }
-
- public Dimension getMaximumSize(JComponent var1) {
- return maxSize;
- }
-
- public Dimension getMinimumSize(JComponent var1) {
- return minSize;
- }
-
- public Dimension getPreferredSize(JComponent var1) {
- return null;
- }
-
- protected void installDefaults() {
- if (this.desktop.getBackground() == null || this.desktop.getBackground() instanceof UIResource) {
- this.desktop.setBackground(UIManager.getColor("Desktop.background"));
- }
-
- }
-
- protected void installDesktopManager() {
- if (this.desktop.getDesktopManager() == null) {
- this.desktopManager = new DefaultDesktopManager();
- this.desktop.setDesktopManager(this.desktopManager);
- }
-
- }
-
- protected void installKeyboardActions() {
- this.minimizeKey = KeyStroke.getKeyStroke(120, 2);
- this.maximizeKey = KeyStroke.getKeyStroke(121, 2);
- this.closeKey = KeyStroke.getKeyStroke(115, 2);
- this.navigateKey = KeyStroke.getKeyStroke(117, 2);
- this.navigateKey2 = KeyStroke.getKeyStroke(9, 2);
- this.registerKeyboardActions();
- }
-
- public void installUI(JComponent var1) {
- this.desktop = (JDesktopPane)var1;
- this.installDefaults();
- this.installDesktopManager();
- this.installKeyboardActions();
- }
-
- public void paint(Graphics var1, JComponent var2) {
- }
-
- protected void registerKeyboardActions() {
- this.desktop.registerKeyboardAction(new MinimizeAction(this), this.minimizeKey, 2);
- this.desktop.registerKeyboardAction(new MaximizeAction(this), this.maximizeKey, 2);
- this.desktop.registerKeyboardAction(new CloseAction(this), this.closeKey, 2);
- this.desktop.registerKeyboardAction(new NavigateAction(this), this.navigateKey2, 2);
- this.desktop.registerKeyboardAction(new NavigateAction(this), this.navigateKey, 2);
- }
-
- protected void uninstallDefaults() {
- }
-
- protected void uninstallDesktopManager() {
- if (this.desktop.getDesktopManager() == this.desktopManager) {
- this.desktop.setDesktopManager((DesktopManager)null);
- }
-
- this.desktopManager = null;
- }
-
- protected void uninstallKeyboardActions() {
- this.unregisterKeyboardActions();
- }
-
- public void uninstallUI(JComponent var1) {
- this.uninstallKeyboardActions();
- this.uninstallDesktopManager();
- this.uninstallDefaults();
- this.desktop = null;
- }
-
- protected void unregisterKeyboardActions() {
- this.desktop.unregisterKeyboardAction(this.minimizeKey);
- this.desktop.unregisterKeyboardAction(this.maximizeKey);
- this.desktop.unregisterKeyboardAction(this.closeKey);
- this.desktop.unregisterKeyboardAction(this.navigateKey);
- this.desktop.unregisterKeyboardAction(this.navigateKey2);
- this.minimizeKey = this.maximizeKey = this.closeKey = this.navigateKey = this.navigateKey2 = null;
- }
- }
-